<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>我要发货</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" href="../css/base.css" />
	<link rel="stylesheet" href="../css/shangjia_fahuo.css" />
	<script src="../js/jquery-2.2.3.min.js"></script>
	<script src="../js/common.js"></script>
	<script type="text/javascript" src="../js/rem.js"></script>
	<style>
		.sureFa{
			display: block;
			height: 0.4rem;
			color: #ffffff !important;
			width: 80%;
			margin: 0.3rem auto 0 auto;
			background: #f59394;
			font-size: 0.16rem;
			line-height: 0.4rem;
			border-radius: 0.1rem;
			text-align: center;
		}
		#fahuo{
			height: 0.4rem;
			line-height: 0.4rem;
			border: 1px solid #f5f5f5;
			width: 1rem;
			outline: none;
		}
		.kd,.remark{
			width: 1.5rem !important;
			border: 1px solid #f5f5f5;
			outline: none;
			text-align: right;
			text-indent: 0.1rem;
			padding-right: 0.1rem;
		}
		</style>
</head>

<body>
	<div class="header">
		<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
		我要发货
	</div>
	<div style="height: 0.44rem;"></div>
	<ul class="orderDetail_type">
		<li class="orderDetail_type_li">
			<p style="position:absolute;left:0.1rem; height: 0.4rem; line-height: 0.4rem;">选择快递公司</p>
			<select name="fahuo" id="fahuo" style="float:right;">

			</select>
		</li>
		<li class="orderDetail_type_li">
			快递单号<input type="text" class="kd" placeholder="请输入快递单号" />
		</li>
	</ul>
	<a href="javascript:0;" class="sureFa" onclick="deliver(this)">确认发货</a>
</body>
<script>
	function GetRequest() {
		//获取url中"?"符后的字串 
		var url = location.search;
		var theRequest = new Object();
		if (url.indexOf("?") != -1) {
			var str = url.substr(1);
			strs = str.split("&");
			for (var i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
			}
		}
		return theRequest;
	}
	var theRequest = GetRequest();
	$.ajax({
		url: SURL + '/jfd/express/getExpressName',
		type: 'get',
		dataType: 'json',
		success: res => {
			res.express.forEach(element => {
				$('#fahuo').append(`
						<option value="${element.expressId}">${element.expressName}</option>
					`)
			});
		}
	})
	function deliver() {
		var orderId = theRequest.id;
		var expressId = $('#fahuo').val();
		var expressNo = $('.kd').val();
		if(expressNo==''){
			alert('物流单号不能为空')
		}
		$.ajax({
			url: SURL + '/jfd/shopOrders/sendGoods',
			type: 'post',
			dataType: 'json',
			data: {
				orderId:orderId,
				expressId:expressId,
				expressNo:expressNo

			},
			success: res => {
				alert(res.msg);
				window.location.href="personal/shangjiaorder.html"
			}
		})
	}
</script>

</html>